/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.amitycs.collabdrawing.gui;

import java.awt.Color;
import java.awt.Shape;
import java.util.ArrayList;
import org.amitycs.collabdrawing.ToolListener;
import org.amitycs.collabdrawing.Whiteboard;

/**
 *
 * @author mike
 */
public abstract class Tool {

    Color color;
    public Tool currTool;
    protected Whiteboard wb;
    private ArrayList<ToolListener> toolListeners;

    public abstract Shape onDrag(double x, double y);
    public abstract Shape onPress(double x, double y);
    public abstract void onRelease(double x, double y);

    public Tool (Whiteboard wb)
    {
        this.wb = wb;
        toolListeners  = new ArrayList<ToolListener>();
    }

    public Color getColor() {
        return color;
    }
    
    protected void fireShapeDone(Shape s)
    {
        for (ToolListener tl : toolListeners)
        {
            tl.shapeDone(s);
        }
    }
    
    public void registerListener(ToolListener tl)
    {
        toolListeners.add(tl);
    }
    
    public void removeListener(ToolListener tl)
    {
        toolListeners.remove(tl);
    }
}
